package com.jieshuibao.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jieshuibao.common.config.Global;
import com.jieshuibao.model.db.H5Course;
import com.jieshuibao.service.H5CourseService;
import com.jieshuibao.util.StringUtils;
import com.jieshuibao.wx.po.WxCourseRres;

@Controller
@RequestMapping("/api")
public class H5CourseController{
	
	@Resource
	private H5CourseService h5CourseService;
	
	@RequestMapping(value="course/{courseid}" , method = RequestMethod.POST)
	@ResponseBody
	public Object getCourse(@PathVariable String courseid){
		WxCourseRres res = new WxCourseRres();
		if(StringUtils.isEmpty(courseid)){
			res.setCode(Global.FAIL);
			res.setDes("系统繁忙");
			return res;
		}
		H5Course h5CourseById = h5CourseService.getH5CourseById(courseid);
		if(null == h5CourseById){
			res.setCode(Global.FAIL);
			res.setDes("系统繁忙");
			return res;
		}
		res.setCode(Global.SUCCESS);
		res.setData(h5CourseById);
		res.setDes("成功");
		return res;
	}
}
